<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Traits\HasDateTimeFormatter;

class OrderPay extends Model
{
    use HasDateTimeFormatter;

    protected $table = 'ims_yz_order_pay';
    protected $guarded = [''];

    // 禁用Laravel的自动时间戳管理
    public $timestamps = false;

    protected $casts = [
        'order_ids' => 'array',
        'amount' => 'decimal:2',
        'status' => 'integer',
        'created_at' => 'integer',
        'updated_at' => 'integer'
    ];

    /**
     * 关联订单
     */
    public function orders()
    {
        return $this->hasMany(Order::class, 'id', 'order_ids');
    }

    /**
     * 关联会员
     */
    public function member()
    {
        return $this->belongsTo(Member::class, 'uid', 'id');
    }
}
